<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class AdminHome extends CI_Controller {

 
	public function index()
	{
		$data['info'] = "请登录!";
		$this->load->view('adminHome',$data);
	}
	
	public function login(){
		// 验证登陆信息
		$username = $_REQUEST['username'];
		$password = $_REQUEST['password'];
		$success = false;
		
//		if( empty($username) || empty($password) ){
//			$success = false;
//			$this->loginError("用户名或密码不能为空!");
//			return ;
//		}
		
		$sql = "SELECT * FROM adminuser WHERE username='$username'";
		$result = $this->db->query($sql) or die("error"); 
		if($result->num_rows() > 0){
			$row = $result->row_array(0);
			if($password == $row['password']){
			$success = true;
			}else{
			$success = false;
			}
		}
		if($success)
		{
			redirect('user/userList/getUsers');
		}else{
		 	$this->loginError("用户名或密码错误!");
		}
	}
	
	// 登录失败时显示的信息
	public function loginError($error=""){
		if($error)
			$data['info'] = $error;
		else 
			$data['info'] = "用户名或密码错误!";
		$this->load->view('adminHome',$data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */









